home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / xinu.arc / CLKINT.MAC next >
Text File  |  1985-09-13  |  1KB  |  72 lines

  1. ;
  2. ;    C L K I N T . M A C
  3. ;
  4. ;    XINU Z80 Clock Interupt Routines
  5. ;    Version 1.0 (Down and Dirty)
  6. ;    S. R. Sampson, September 1985
  7. ;
  8. ;    Do Xinu interupt processing.
  9. ;
  10.  
  11. clkint::
  12.     push    h
  13.     push    d
  14.     push    b
  15.     push    psw
  16.  
  17.     lhld    count50##
  18.     dcx    h
  19.     shld    count50##
  20.     mov    a,h
  21.     ora    l
  22.     jnz    around        ; Ignore first 50 interupts (50x.002=.1 Sec)
  23.                 ; Heathkit H89 has 2ms interupts
  24.     lxi    h,50
  25.     shld    count50##
  26.     lhld    defclk##    ; See if clock is deferred
  27.     mov    a,h
  28.     ora    l
  29.     jz    notdef
  30.  
  31.     lhld    clkdiff##
  32.     inx    h
  33.     shld    clkdiff##    ; Yes, so increment defer count
  34.     jmp    around        ; And return to system
  35.  
  36. notdef:
  37.     lhld    slnempty##    ; is sleep queue nonempty?
  38.     mov    a,h
  39.     ora    l
  40.     jz    clpreem        ; empty, go process preemption
  41.     lhld    sltop##        ; yes, decrement delta key
  42.     mov    e,m
  43.     inx    h
  44.     mov    d,m
  45.     dcx    d
  46.     mov    a,d
  47.     ora    e
  48.     mov    m,d
  49.     dcx    h
  50.     mov    m,e
  51.     jnz    clpreem
  52.     call    wakeup##    ; wakeup when sleep is done
  53.  
  54. clpreem:
  55.     lhld    preempt##    ; decrement preemption counter
  56.     dcx    h
  57.     shld    preempt##
  58.     mov    a,h
  59.     ora    l
  60.     jnz    around
  61.     call    resched##    ; timeshare
  62.  
  63. around:
  64.     pop    psw
  65.     pop    b
  66.     pop    d
  67.     pop    h
  68.     ei
  69.     ret
  70.  
  71.     end
  72.